package com.tju.resource.business.tb_rm_store.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tju.resource.business.tb_rm_store.TbRmStoreService;
import com.tju.resource.mapper.TbRmStoreMapper;
import com.tju.resource.model.TbRmStore;
import com.tju.resource.result.Result;
import com.tju.resource.result.ResultEnum;
import com.tju.resource.result.ResultUtil;
import com.tju.resource.tool.tool.EmptyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class TbRmStoreServiceImpl extends ServiceImpl<TbRmStoreMapper, TbRmStore>
        implements TbRmStoreService {
    @Autowired
    private TbRmStoreMapper tbRmStoreMapper;

    /**
     * 查询原料入库记录
     *
     * @param params
     * @return
     */
    @Override
    public Result<Object> selectTbRmStore(Map<String, String> params) {
        if (EmptyUtils.isNotEmpty(params.get("page")) && EmptyUtils.isNotEmpty(params.get("limit"))) {
            Page<TbRmStore> page = new Page<>(Long.parseLong(params.get("page")), Long.parseLong(params.get("limit")));
            IPage<TbRmStore> iPage = tbRmStoreMapper.selectTbRmStore(page, params);
            List<TbRmStore> records = iPage.getRecords(); //发料记录
            return ResultUtil.success(ResultEnum.SUCCESS, records, records.size());
        }
        return ResultUtil.error(ResultEnum.UNKONW_ERROR, "缺少参数!");
    }
    
}




